#ifndef __BASIC_TASK_EXECUTOR_H__
#define __BASIC_TASK_EXECUTOR_H__

#include "basic/platform.h"
#include "basic/types.h"

namespace basic
{
namespace task_executor
{

    enum class M_API_FUNC ETaskStatus : short {
        UNKNOWN = -1,
        INITED = 0,
        READY_TO_EXECUTE,
        EXECUTING,
        FINISHED_EXECUTING,
        CANCELED,
        DONE,
        FAILED,
    };

    class M_API_FUNC Task
    {
      public:
        Task() = default;
        virtual ~Task() = default;
        virtual void Execute() = 0;
        ETaskStatus GetStatus() const noexcept
        {
            return m_status;
        }

      private:
        ETaskStatus m_status{ETaskStatus::INITED};
        friend class TaskExecutorInner;
    };

    class M_API_FUNC TaskExecutor final
    {
      public:
        TaskExecutor() = delete;
        TaskExecutor(int numberThreads);
        ~TaskExecutor();

        bool AddTask(Task* pt);
        bool RemoveTask(Task* pt);
    };

} // namespace task_executor
} // namespace basic

#endif // DUCK_DK_TASK_EXECUTOR_H
